header_rewrite: count operators and conditions run#13286
Open
moonchen wants to merge 1 commit into
Open
Conversation
The per-hook invocation count cannot tell a small ruleset from a large one,
so it does not reflect how much work header_rewrite does per transaction.
Add proxy.process.plugin.header_rewrite.{operators,conditions}, incremented
in the inline Operator::do_exec and Condition::do_eval chain walkers, to make
that workload visible. do_eval short-circuits, so only conditions actually
evaluated are counted. The counters are created once, from both TSPluginInit
and TSRemapInit.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds process metrics to quantify how much work the header_rewrite plugin performs by counting how many operators are executed and conditions are evaluated. It also extends the AuTest replay harness to validate these metrics in gold tests.
Changes:
- Add
proxy.process.plugin.header_rewrite.{operators,conditions}stats and increment them on each operator/condition execution. - Initialize the stats from both global plugin init (
TSPluginInit) and remap init (TSRemapInit). - Extend
ATSReplayTestto support metric checks with a minimum threshold and add a gold test that asserts the new metrics are non-zero.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/gold_tests/pluginTest/header_rewrite/header_rewrite_bundle.replay.yaml | Adds metric checks ensuring the new header_rewrite counters are incrementing. |
| tests/gold_tests/autest-site/ats_replay.test.ext | Extends metric check handling to support min thresholds (but currently contains an awk field bug). |
| plugins/header_rewrite/statement.h | Declares global stat IDs and an initialization helper for work stats. |
| plugins/header_rewrite/statement.cc | Defines the stat IDs and creates the new stats. |
| plugins/header_rewrite/operator.h | Increments the operator-executed metric per operator execution. |
| plugins/header_rewrite/condition.h | Increments the condition-evaluated metric per condition evaluation. |
| plugins/header_rewrite/header_rewrite.cc | Calls stats initialization during plugin init and remap init. |
JosiahWI
requested changes
Jun 19, 2026
| bool | ||
| do_eval(const Resources &res) | ||
| { | ||
| // In do_eval, so AND/OR short-circuited conditions aren't counted. |
Comment on lines
+35
to
+37
| // Counters for the number of header_rewrite operators executed and conditions evaluated; the | ||
| // bare hook invocation count cannot tell a small ruleset from a large one. Created once via | ||
| // init_hrw_work_stats(); both are TS_ERROR until then, so increments are guarded. |
Contributor
There was a problem hiding this comment.
Is init_hrw_work_stats not serialized with the hook registration?
| // Plugin init is single-threaded, so the create-once guard is safe. header_rewrite.so can | ||
| // be loaded both globally and as a remap plugin; both must share one process-wide stat. | ||
| if (TS_ERROR == hrw_stat_operators) { | ||
| hrw_stat_operators = TSStatCreate("proxy.process.plugin.header_rewrite.operators", TS_RECORDDATATYPE_INT, |
Contributor
There was a problem hiding this comment.
Our API documentation says that TsStatCreate is deprecated since ATS 10, and that we should use the Metrics.h APIs instead. I think we should heed that if possible.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add proxy.process.plugin.header_rewrite.{operators,conditions} to track how much work header_rewrite does. These increment each time an operator or condition is executed.